package com.application.run;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;

import com.application.model.utils.ManagerFile;

public class UtilsRunClass {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			DOMConfigurator.configure("./config/log4j.xml");
			Logger logger = Logger.getLogger(UtilsRunClass.class);
			String datos = getDatos();
			String regex = "<h3>(.*?)</h3>";
	        Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL | Pattern.UNICODE_CASE | Pattern.UNIX_LINES);
	        Matcher matcher = pattern.matcher(datos);
	        while (matcher.find()) {
	        	logger.info("insert into partido(name,provincia_id) VALUES('"+matcher.group(1)+"',(select id from provincia where name = 'G.B.A. Zona Norte' AND pais_id = (select id from pais where name ='Argentina')));");
	        }
        } catch (Exception e) {
            e.printStackTrace();
        }
	}

	private static String getDatos() {
		
		String value = "";
		try {
			value = ManagerFile.getContenido("./log/ZonaNorte.log");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return value;
	}

}
